Skip to content

lite-site: skip module init when Newspack Lite Site plugin is active#4720

Merged
miguelpeixe merged 2 commits into
Automattic:trunkfrom
R1shabh-Gupta:fix/lite-site-conflict-standalone-plugin
May 13, 2026
Merged

lite-site: skip module init when Newspack Lite Site plugin is active#4720
miguelpeixe merged 2 commits into
Automattic:trunkfrom
R1shabh-Gupta:fix/lite-site-conflict-standalone-plugin

Conversation

@R1shabh-Gupta

Copy link
Copy Markdown
Contributor

Description

When the Newspack Lite Site plugin (code here) is active alongside newspack-plugin, both register identical WordPress identifiers and the same settings group (newspack_lite_site), option name (newspack_lite_site_settings), admin menu slug (newspack-lite-site), and rewrite rules. This causes:

  • Doubled settings forms on the Settings > Lite Site admin page and Lite Site → Settings & Appearance page
  • Duplicate sanitize callbacks stacked on sanitize_option_newspack_lite_site_settings.
  • Conflicting rewrite rules registered twice

The standalone plugin defines NEWSPACK_LITE_SITE_PLUGIN_FILE in its main file at load time. Guarding Lite_Site::init() with a check for that constant prevents the built-in module from initializing at all when the standalone plugin is active, eliminating all four collision points.

All Submissions:

Changes proposed in this Pull Request:

Wrap Lite_Site::init() in includes/lite-site/class-lite-site.php with a defined( 'NEWSPACK_LITE_SITE_PLUGIN_FILE' ) guard so the built-in lite-site module is a no-op when the Newspack Lite Site plugin is active.

How to test the changes in this Pull Request:

  1. Activate both newspack-plugin and the Newspack Lite Site plugin.
  2. Navigate to Lite Site → Settings & Appearance and confirm only one settings form is rendered.
  3. Save settings (e.g. toggle "Enable Lite Site", set a URL base) and confirm values persist correctly on reload with no fields stripped.
  4. Check the Settings menu and confirm no "Lite Site" entry appears there.
  5. Deactivate the standalone plugin and confirm the built-in Settings → Lite Site page is still fully functional (module initialises normally when NEWSPACK_LITE_SITE_PLUGIN_FILE is undefined).

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@R1shabh-Gupta R1shabh-Gupta marked this pull request as ready for review May 13, 2026 14:28
@R1shabh-Gupta R1shabh-Gupta requested a review from a team as a code owner May 13, 2026 14:28

@miguelpeixe miguelpeixe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @R1shabh-Gupta!

It's best to hook this under plugins_loaded to ensure the Lite Site plugin is loaded.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents the built-in Lite Site module inside newspack-plugin from initializing when the standalone Newspack Lite Site plugin is active, avoiding collisions on shared identifiers (settings group/option name, menu slug, and rewrite rules).

Changes:

  • Add an early defined( 'NEWSPACK_LITE_SITE_PLUGIN_FILE' ) guard inside Lite_Site::init() to no-op when the standalone plugin is present.
  • Switch module bootstrapping from an immediate Lite_Site::init(); call to a plugins_loaded hook so the constant check reliably reflects other loaded plugins.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@miguelpeixe miguelpeixe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for revising!

@miguelpeixe miguelpeixe merged commit a17cf24 into Automattic:trunk May 13, 2026
11 checks passed
matticbot pushed a commit that referenced this pull request May 21, 2026
# [6.42.0-alpha.1](v6.41.0...v6.42.0-alpha.1) (2026-05-21)

### Bug Fixes

* **donations:** add reset method for flagged products cache ([#4709](#4709)) ([56ec746](56ec746))
* **integrations:** normalize inbound option shape in configure view ([#4717](#4717)) ([262c968](262c968))
* **lite-site:** skip module init when Lite Site plugin is active ([#4720](#4720)) ([a17cf24](a17cf24))
* prevent recursion in lite-site primary color on block themes ([#4747](#4747)) ([1771dc0](1771dc0))

### Features

* **access-control:** add group subscription identifier to metadata ([#4697](#4697)) ([8d71495](8d71495)), closes [#8217](https://github.com/Automattic/newspack-plugin/issues/8217)
* **alert-manager:** route alerts to Slack via newspack_log ([#4723](#4723)) ([6e68ab6](6e68ab6))
* **analytics:** auto-provision GA4 custom dimensions ([#4657](#4657)) ([e3373cf](e3373cf))
* **cli:** teams-for-memberships diagnostics command ([#4662](#4662)) ([df92456](df92456))
* **donations:** add option to flag any WooCommerce product as a donation ([#4635](#4635)) ([5860c8b](5860c8b))
* **group-subs:** polish invite-links UX in My Account ([#4719](#4719)) ([1b639c4](1b639c4))
* **group-subs:** shareable invite links ([#4704](#4704)) ([76706f5](76706f5))
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 6.42.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

adekbadek pushed a commit to Automattic/newspack-workspace that referenced this pull request May 28, 2026
* **donations:** add reset method for flagged products cache ([#4709](Automattic/newspack-plugin#4709)) ([013c383](Automattic/newspack-plugin@013c383))
* **integrations:** normalize inbound option shape in configure view ([#4717](Automattic/newspack-plugin#4717)) ([7a20a2e](Automattic/newspack-plugin@7a20a2e))
* **lite-site:** skip module init when Lite Site plugin is active ([#4720](Automattic/newspack-plugin#4720)) ([aba85e0](Automattic/newspack-plugin@aba85e0))
* prevent recursion in lite-site primary color on block themes ([#4747](Automattic/newspack-plugin#4747)) ([b771fa0](Automattic/newspack-plugin@b771fa0))

* **access-control:** add group subscription identifier to metadata ([#4697](Automattic/newspack-plugin#4697)) ([65b50d3](Automattic/newspack-plugin@65b50d3)), closes [#8217](https://github.com/Automattic/newspack-plugin/issues/8217)
* **alert-manager:** route alerts to Slack via newspack_log ([#4723](Automattic/newspack-plugin#4723)) ([e56293d](Automattic/newspack-plugin@e56293d))
* **analytics:** auto-provision GA4 custom dimensions ([#4657](Automattic/newspack-plugin#4657)) ([1e4f56d](Automattic/newspack-plugin@1e4f56d))
* **cli:** teams-for-memberships diagnostics command ([#4662](Automattic/newspack-plugin#4662)) ([15da7ee](Automattic/newspack-plugin@15da7ee))
* **donations:** add option to flag any WooCommerce product as a donation ([#4635](Automattic/newspack-plugin#4635)) ([08dd002](Automattic/newspack-plugin@08dd002))
* **group-subs:** polish invite-links UX in My Account ([#4719](Automattic/newspack-plugin#4719)) ([6ced5ea](Automattic/newspack-plugin@6ced5ea))
* **group-subs:** shareable invite links ([#4704](Automattic/newspack-plugin#4704)) ([05a8d50](Automattic/newspack-plugin@05a8d50))

(cherry picked from commit 2d2a341e069b52acbbe3d4679b85433170da16e4)
matticbot pushed a commit that referenced this pull request Jun 1, 2026
# [6.43.0-alpha.1](v6.42.0...v6.43.0-alpha.1) (2026-06-01)

### Bug Fixes

* **donations:** add reset method for flagged products cache ([#4709](#4709)) ([56ec746](56ec746))
* **integrations:** normalize inbound option shape in configure view ([#4717](#4717)) ([262c968](262c968))
* **lite-site:** skip module init when Lite Site plugin is active ([#4720](#4720)) ([a17cf24](a17cf24))
* prevent recursion in lite-site primary color on block themes ([#4747](#4747)) ([1771dc0](1771dc0))

### Features

* **access-control:** add group subscription identifier to metadata ([#4697](#4697)) ([8d71495](8d71495)), closes [#8217](https://github.com/Automattic/newspack-plugin/issues/8217)
* **alert-manager:** route alerts to Slack via newspack_log ([#4723](#4723)) ([6e68ab6](6e68ab6))
* **analytics:** auto-provision GA4 custom dimensions ([#4657](#4657)) ([e3373cf](e3373cf))
* **cli:** teams-for-memberships diagnostics command ([#4662](#4662)) ([df92456](df92456))
* **donations:** add option to flag any WooCommerce product as a donation ([#4635](#4635)) ([5860c8b](5860c8b))
* **group-subs:** polish invite-links UX in My Account ([#4719](#4719)) ([1b639c4](1b639c4))
* **group-subs:** shareable invite links ([#4704](#4704)) ([76706f5](76706f5))
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 6.43.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants